home *** CD-ROM | disk | FTP | other *** search
/ Workplace Effectiveness:…ecision-Making Strategies / Workplace Effectiveness: Decision-Making Strategies.iso / pc / Files / History.dxr / 00003_Navigation handlers.ls < prev    next >
Encoding:
Text File  |  1998-12-16  |  6.2 KB  |  204 lines

  1. global gMasterData, gSection, gHistoryList, gQuestionNum, gHistoryAnswerList, gQuestions
  2.  
  3. on goIntro
  4.   go(label("intro"))
  5.   set gSection to #intro
  6.   goNarrator(gMasterData, "21")
  7. end
  8.  
  9. on setUpHistory
  10.   stopSound2()
  11.   go("History1")
  12.   goNarrator(gMasterData, "22")
  13.   set gSection to #history
  14.   set gQuestionNum to 1
  15.   if voidp(gHistoryList) then
  16.     set gHistoryList to [#empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty, #empty]
  17.   end if
  18.   if voidp(gHistoryAnswerList) then
  19.     set gHistoryAnswerList to [#no, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #no, #yes, #no, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes, #yes]
  20.   end if
  21.   showTheChoice()
  22. end
  23.  
  24. on goBackTo28
  25.   stopSound2()
  26.   go("History1")
  27.   set gSection to #history
  28.   set gQuestionNum to 28
  29.   set the member of sprite 3 to member ("question" && gQuestionNum)
  30.   set the member of sprite 9 to member "done up"
  31.   showTheChoice()
  32. end
  33.  
  34. on historyChoice vTheseButtons, vThisChoice, vThisSprite
  35.   repeat with X in vTheseButtons
  36.     if X = vThisSprite then
  37.       nothing()
  38.       next repeat
  39.     end if
  40.     case 1 of
  41.       (X = 5):
  42.         set the memberNum of sprite X to the number of member "yes"
  43.       (X = 6):
  44.         set the memberNum of sprite X to the number of member "no"
  45.       (X = 7):
  46.         set the memberNum of sprite X to the number of member "not"
  47.     end case
  48.   end repeat
  49.   updateStage()
  50.   setAt(gHistoryList, gQuestionNum, vThisChoice)
  51. end
  52.  
  53. on nextQuestion
  54.   if gQuestionNum < 28 then
  55.     set gQuestionNum to gQuestionNum + 1
  56.     set the member of sprite 3 to member ("question" && gQuestionNum)
  57.     showTheChoice()
  58.     if gQuestionNum = 28 then
  59.       set the member of sprite 9 to member "done up"
  60.     end if
  61.     updateStage()
  62.   else
  63.     prepareGraph()
  64.   end if
  65. end
  66.  
  67. on prevQuestion
  68.   if gQuestionNum > 1 then
  69.     if gQuestionNum = 28 then
  70.       set the member of sprite 9 to member "next up"
  71.     end if
  72.     updateStage()
  73.     set gQuestionNum to gQuestionNum - 1
  74.     set the member of sprite 3 to member ("question" && gQuestionNum)
  75.     showTheChoice()
  76.   end if
  77. end
  78.  
  79. on showTheChoice
  80.   set vAnswer to getAt(gHistoryList, gQuestionNum)
  81.   set the memberNum of sprite 5 to the number of member "yes"
  82.   set the memberNum of sprite 6 to the number of member "no"
  83.   set the memberNum of sprite 7 to the number of member "not"
  84.   case vAnswer of
  85.     #yes:
  86.       set the member of sprite 5 to member "yes on"
  87.     #no:
  88.       set the member of sprite 6 to member "no on"
  89.     #not:
  90.       set the member of sprite 7 to member "not on"
  91.   end case
  92.   updateStage()
  93. end
  94.  
  95. on prepareGraph
  96.   go("history2")
  97.   setUpQuestions()
  98.   set gSection to #graph
  99.   set vAnswerKey to [#home: [2, 9, 10, 14, 17, 22, 28], #work: [1, 3, 5, 7, 19, 26, 27], #relationship: [4, 6, 16, 18, 20, 21, 23], #self: [8, 11, 12, 13, 15, 24, 25]]
  100.   set vGraphResult to [#home: [0, 0], #work: [0, 0], #relationship: [0, 0], #self: [0, 0]]
  101.   repeat with X = 1 to count(gHistoryList)
  102.     repeat with vProp in [#home, #work, #relationship, #self]
  103.       if getOne(getProp(vAnswerKey, vProp), X) <> 0 then
  104.         set vPick1 to getAt(gHistoryList, X)
  105.         set vCorrectAns1 to getAt(gHistoryAnswerList, X)
  106.         case 1 of
  107.           (vPick1 = vCorrectAns1):
  108.             set vTester to 1
  109.           (vPick1 = #not):
  110.             set vTester to 0
  111.           (vPick1 = #empty):
  112.             set vTester to 0
  113.           otherwise:
  114.             set vTester to 2
  115.         end case
  116.         if vTester > 0 then
  117.           set vThisNum to getAt(getProp(vGraphResult, vProp), vTester)
  118.           set vThisNum to vThisNum + 1
  119.           setAt(getProp(vGraphResult, vProp), vTester, vThisNum)
  120.         end if
  121.       end if
  122.     end repeat
  123.   end repeat
  124.   showGraph(vGraphResult)
  125.   calculatePrint(vGraphResult)
  126. end
  127.  
  128. on showGraph vGraphResult
  129.   global gMasterData
  130.   set vThisSprite to 5
  131.   set bottomV to 348
  132.   set topV to 158
  133.   set vNewNotch to (bottomV - topV) / 7
  134.   repeat with vProp in [#home, #work, #relationship, #self]
  135.     repeat with vListPos = 1 to 2
  136.       set vAnswer to getAt(getProp(vGraphResult, vProp), vListPos)
  137.       if vAnswer > 0 then
  138.         set vEndPositionV to bottomV - (vAnswer * vNewNotch)
  139.         AnimateGraph(vThisSprite, vEndPositionV)
  140.       end if
  141.       set vThisSprite to vThisSprite + 1
  142.     end repeat
  143.   end repeat
  144.   goNarrator(gMasterData, "23")
  145. end
  146.  
  147. on AnimateGraph vThisSprite, vEndPositionV
  148.   set vStartLocH to the locH of sprite vThisSprite
  149.   set vNewLocV to the locV of sprite vThisSprite
  150.   repeat while vNewLocV >= vEndPositionV
  151.     set vNewLocV to vNewLocV - 2
  152.     set the loc of sprite vThisSprite to point(vStartLocH, vNewLocV)
  153.     updateStage()
  154.   end repeat
  155. end
  156.  
  157. on setUpQuestions
  158.   set gQuestions to [#questionNum: 1, #artSprite: 17, #fieldSprite: 18, #numofquestions: 5]
  159. end
  160.  
  161. on questionNext
  162.   if the questionNum of gQuestions < the numofquestions of gQuestions then
  163.     set the questionNum of gQuestions to the questionNum of gQuestions + 1
  164.     nextQuest()
  165.   else
  166.     if not activationOn(gMasterData) then
  167.       activate(gMasterData)
  168.     end if
  169.   end if
  170. end
  171.  
  172. on questionPrev
  173.   if the questionNum of gQuestions > 1 then
  174.     set the questionNum of gQuestions to the questionNum of gQuestions - 1
  175.     nextQuest()
  176.   end if
  177. end
  178.  
  179. on nextQuest
  180.   set the member of sprite the artSprite of gQuestions to member ("quest" && the questionNum of gQuestions)
  181.   set the member of sprite the fieldSprite of gQuestions to member ("decision field" && the questionNum of gQuestions) of castLib "Shared"
  182.   updateStage()
  183. end
  184.  
  185. on calculatePrint vGraphResult
  186.   set the floatPrecision to 0
  187.   set vLine to 8
  188.   set vText to EMPTY
  189.   repeat with vProp in [#home, #work, #relationship, #self]
  190.     repeat with vListPos = 1 to 2
  191.       set vAnswer to getAt(getProp(vGraphResult, vProp), vListPos)
  192.       set X to vAnswer / 7.0 * 100.0
  193.       case vListPos of
  194.         1:
  195.           put "Your" && vProp && "effectiveness percentage is" && X & "." & RETURN after vText
  196.         2:
  197.           put "Your" && vProp && "ineffectiveness percentage is" && X & "." & RETURN after vText
  198.       end case
  199.       set vLine to vLine + 1
  200.     end repeat
  201.   end repeat
  202.   set the text of field "print2" to vText
  203. end
  204.